<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich">

<body>
	<ui:composition template="/template/template.xhtml">
		<ui:define name="body">
			<h:form onkeypress="if (event.keyCode == 13) return false;">

				<rich:notifyMessages stayTime="2000" nonblocking="true" />
		
				<h:panelGrid>
					<rich:accordion switchType="client" id="acc_panel" style="width:1000px" >
						<rich:accordionItem id="search_pane" header="#{msg.search}" style="font-size: 16px;">
							<table>
								<tr>
									<td><h:outputText value="#{msg.building_name}" styleClass="outputText" style="font-size: 16px;" /></td>
									<td>
										<h:selectOneMenu id="search_building_name" styleClass="selectClass" 
											value="#{scheduleManageBean.selectedBuildingId}" valueChangeListener="#{scheduleManageBean.buildingValueChanged}">
			
											<f:selectItems value="#{scheduleManageBean.buildingOptions}" />
											<a4j:ajax event="valueChange" render="search_floor_name,search_room_name,search_machine_name" execute="@this" />
			
										</h:selectOneMenu>
									</td>
								
									<td><h:outputText value="#{msg.floor_name}" styleClass="outputText" style="font-size: 16px;" /></td>
									<td>
										<h:selectOneMenu id="search_floor_name" styleClass="selectClass" 
											value="#{scheduleManageBean.selectedFloorId}" valueChangeListener="#{scheduleManageBean.floorValueChanged}">
			
											<f:selectItems value="#{scheduleManageBean.floorOptions}" />
											<a4j:ajax event="valueChange" render="search_room_name,search_machine_name" execute="@this" />
										</h:selectOneMenu>
									</td>
								</tr>
								
								<tr>
									<td><h:outputText value="#{msg.room_name}" styleClass="outputText" style="font-size: 16px;" /></td>
									<td>
										<h:selectOneMenu id="search_room_name" styleClass="selectClass" 
											value="#{scheduleManageBean.selectedRoomId}" valueChangeListener="#{scheduleManageBean.roomValueChanged}">
											
											<f:selectItems value="#{scheduleManageBean.roomOptions}" />
											<a4j:ajax event="valueChange" render="search_machine_name" execute="@this" />
											
										</h:selectOneMenu>
									</td>
								
									<td><h:outputText value="#{msg.machine_name}" styleClass="outputText" style="font-size: 16px;" /></td>
									<td>
										<h:selectOneMenu id="search_machine_name" styleClass="selectClass" 
											value="#{scheduleManageBean.selectedMachineId}">
											
											<f:selectItems value="#{scheduleManageBean.machineOptions}" />																
										</h:selectOneMenu>
									</td>
								</tr>
								
								<tr>
									<td colspan="4" align="left">
										<a4j:commandButton styleClass="buttonClass" style="font-size: 16px;" 
											value="#{msg.search}" action="#{scheduleManageBean.search}"
											oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('acc_panel')}.switchToItem('select_pane');}"  
											render="select_pane" />
									</td>
											 						
								</tr>
							</table>
						</rich:accordionItem>
					
						<rich:accordionItem id="select_pane" header="#{msg.select}" style="font-size: 16px;">
					
							<table>								
								<tr>
									<td>								
										<h:selectManyCheckbox id="clickedMachine" 		
											layout="pageDirection" style="font-size: 16px;" 								
											value="#{scheduleManageBean.clickedMachineId}">
								   			<f:selectItems value="#{scheduleManageBean.clickedMachineOptions}" />					   			
								   		</h:selectManyCheckbox>
								   										   		
								   		<h:outputText value="#{msg.no_record_found}" rendered="#{empty scheduleManageBean.clickedMachineOptions}" />
								   	</td>
								</tr>
								<tr>
									<td>
										<a4j:commandButton styleClass="buttonClass" style="font-size: 16px;" 
												value="#{msg.back}" oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('acc_panel')}.switchToItem('search_pane');}" />
										<a4j:commandButton styleClass="buttonClass" style="font-size: 16px;" 
											value="#{msg.view}" action="#{scheduleManageBean.view}"
											oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('acc_panel')}.switchToItem('detail_pane');}"  
											render="dataTable" />
									</td>
								</tr>
							</table>
						</rich:accordionItem>
						
						<rich:accordionItem id="detail_pane" header="#{msg.detail}" style="font-size: 16px;">
							<a4j:commandLink id="createPane_btn" value="#{msg.create}"
								styleClass="buttonClass" style="font-size: 16px;"
								execute="@this" render="@none"
								oncomplete="#{rich:component('createPane')}.show();" >
							
								<rich:componentControl event="click" operation="show" target="createPane">
					                <a4j:param name="event" value="event" noEscape="true" />
					                <rich:hashParam>
					                    <a4j:param noEscape="true" name="top"
					                        value="jQuery(#{rich:element('createPane_btn')}.parentNode).offset().top" />
					                    <a4j:param noEscape="true" name="left" value="jQuery(#{rich:element('createPane_btn')}.parentNode).offset().left" />
					                </rich:hashParam>
					            </rich:componentControl>
								
							</a4j:commandLink>		
							<rich:extendedDataTable id="dataTable" width="100%" rows="15" frozenColumns="3"
								value="#{scheduleManageBean.scheduleTerms}" var="scheduleTerm" iterationStatusVar="it">
								
								<f:facet name="noData">
									<h:outputText value="#{msg.no_record_found}" />
								</f:facet>
								
								<rich:column width="210px"
									sortBy="#{scheduleTerm.machineName}"
									sortOrder="#{scheduleManageBean.sortsOrders['machine_machinename']}">
									
									<f:facet name="header">			                
						                <h:panelGrid columns="2">
											<a4j:commandLink style="color:#FFFFFF" styleClass="tableTitle"
												value="#{msg.machine_name}" render="@form"
												action="#{scheduleManageBean.sort}" execute="@this" immediate="true" > 									
												<f:param name="sortProperty" value="machine_machinename" />							
											</a4j:commandLink>
			
											<h:graphicImage library="images" name="icons/down_icon.gif"
												rendered="#{scheduleManageBean.sortsOrders['machine_machinename']=='descending'}" />
			
											<h:graphicImage library="images"
												name="icons/up_icon.gif.gif"
												rendered="#{scheduleManageBean.sortsOrders['machine_machinename']=='ascending'}" />
			
										</h:panelGrid>
						            </f:facet>		
									<h:outputText value="#{scheduleTerm.machine.machineName}" />
								</rich:column>				
								
							</rich:extendedDataTable>
						</rich:accordionItem>
					</rich:accordion>
				</h:panelGrid>

			</h:form>

		</ui:define>
	</ui:composition>
</body>
</html>
